<?php
/**
 * CRMLite Default Admin Controller
 *
 * @final
 * @package Crmlite_App
 * @version $Id: BaseController.php 47 2007-09-04 14:11:49Z etng2004 $
 * @copyright 2006-2007 ETE.CN
 * @author Yi BO  <etng2004@gmail.com>
 * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
 */

abstract class BaseController extends Crmlite_Controller_Action
{
	public function init()
	{
		parent::init();
		$this->session = new Zend_Session_Namespace('Default');
		$this->path['root']['link'] = $this->module_url?$this->module_url:'/';
		$this->view->show_path = true;
	}
    public function preDispatch()
    {
		return true;
    }

	public function postDispatch()
	{
		$AM = new AnnounceModel();
		$where = array(
		'expired_at = 0 OR DATE(FROM_UNIXTIME(expired_at)) >= CURDATE()',
		'published_at = 0 OR DATE(FROM_UNIXTIME(published_at)) <= CURDATE()',
		);
		$order = 'created_at DESC';
		$this->view->latest_announces = $AM->findAll($where, $order, 10);

		$this->view->page		= $this->page;
		$this->view->path		= $this->path;
	}
    public function feedback($messgae, $title, $backUrl = '/', $icon = 'note')
    {
        $param = array(
            'message'   =>  $messgae,
            'title'     =>  $title,
            'url'       =>  $backUrl,
            'icon'      =>  $icon,
        );
        $request = $this->getRequest();
        $module  = $request->getModuleName();
        $this->_forward('message', 'index', $module, $param);
    }
}